package com.fr.base.core.antlr;

import com.fr.base.core.antlr.collections.AST;

public class ASTIterator
{
  protected AST cursor = null;
  protected AST original = null;

  public boolean isSubtree(AST paramAST1, AST paramAST2)
  {
    if (paramAST2 == null)
      return true;
    if (paramAST1 == null)
      return (paramAST2 == null);
    AST localAST = paramAST1;
    while ((localAST != null) && (paramAST2 != null))
    {
      if (localAST.getType() != paramAST2.getType())
        return false;
      if ((localAST.getFirstChild() != null) && (!(isSubtree(localAST.getFirstChild(), paramAST2.getFirstChild()))))
        return false;
      localAST = localAST.getNextSibling();
      paramAST2 = paramAST2.getNextSibling();
    }
    return true;
  }

  public AST next(AST paramAST)
  {
    Object localObject1 = null;
    Object localObject2 = null;
    if (this.cursor == null)
      return null;
    while (this.cursor != null)
    {
      if ((this.cursor.getType() == paramAST.getType()) && (this.cursor.getFirstChild() != null) && (isSubtree(this.cursor.getFirstChild(), paramAST.getFirstChild())))
        return this.cursor;
      this.cursor = this.cursor.getNextSibling();
    }
    return localObject1;
  }
}